package com.tanhua.server.job;

import com.tanhua.domain.db.UserInfo;
import com.tanhua.domain.mongo.Sound;
import com.tanhua.domain.vo.SoundVo;
import com.tanhua.dubbo.api.SoundApi;
import com.tanhua.dubbo.api.UserApi;
import com.tanhua.dubbo.api.UserInfoApi;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author WDY
 * @date Created in 2021/3/1 16:45
 * @modified By  WDY in 2021/3/1 16:45
 * @description
 */

@Component
public class SoundJob {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;
    @Reference
    private UserInfoApi userInfoApi;
    /**
     * 每天重新统计桃花传音剩余次数
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void getCount() {
        List<Long> userIdList = userInfoApi.queryAll();
        for (Long userId : userIdList) {

            redisTemplate.delete("COUNT_TANHUA_SOUND_"+ userId);
        }


    }
}